﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.ValentineUI {
    import flash.display.*;
    import org.aswing.*;
    import Modules.franchise.display.*;
    import org.aswing.event.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class AchievementsScrollingList extends FranchiseTabScrollingList {

        public static const NUM_ITEMS:int = 4;
        protected static const ROW_HEIGHT:int = 308;
        protected static const ROW_WIDTH:int = 548;

        public function AchievementsScrollingList(_arg1:Array, _arg2:Class, _arg3:int, _arg4:int=0, _arg5:int=1){
            super(_arg1, _arg2, _arg3, _arg4, _arg5, NUM_ITEMS);
            this.removeAll();
            this.makeSize();
            this.append(prevButton);
            this.appendAll(ASwingHelper.horizontalStrut(10), m_scrollPane, ASwingHelper.horizontalStrut(10));
            this.append(nextButton);
            ASwingHelper.prepare(this);
        }
        override protected function makeButtons():void{
            var _local1:DisplayObject = (new (ValentineDialog.assetDict["prev_normal"])() as DisplayObject);
            var _local2:DisplayObject = (new (ValentineDialog.assetDict["prev_down"])() as DisplayObject);
            var _local3:DisplayObject = (new (ValentineDialog.assetDict["prev_over"])() as DisplayObject);
            var _local4:DisplayObject = (new (ValentineDialog.assetDict["next_normal"])() as DisplayObject);
            var _local5:DisplayObject = (new (ValentineDialog.assetDict["next_down"])() as DisplayObject);
            var _local6:DisplayObject = (new (ValentineDialog.assetDict["next_over"])() as DisplayObject);
            prevButton = new JButton();
            prevButton.wrapSimpleButton(new SimpleButton(_local1, _local3, _local2, _local1));
            prevButton.setEnabled(false);
            nextButton = new JButton();
            nextButton.wrapSimpleButton(new SimpleButton(_local4, _local6, _local5, _local4));
            if (m_data.length <= NUM_ITEMS){
                nextButton.setEnabled(false);
            } else {
                nextButton.setEnabled(true);
            };
            prevButton.addActionListener(this.moveLeft, 0, true);
            nextButton.addActionListener(this.moveRight, 0, true);
        }
        override protected function makeTabs(_arg1:int=4):void{
            m_model = new VectorListModel();
            var _local2:int = Math.min(_arg1, m_data.length);
            var _local3:int;
            while (_local3 < _local2) {
                m_model.append(m_data[_local3]);
                m_curCount++;
                _local3++;
            };
            m_dataList = new GridList(m_model, m_cellFactory, m_columns, m_rows);
            m_dataList.setHGap(0);
            m_scrollPane = new JScrollPane(m_dataList, JScrollPane.SCROLLBAR_NEVER, JScrollPane.SCROLLBAR_NEVER);
        }
        override protected function makeSize():void{
            this.setPreferredHeight(ROW_HEIGHT);
            m_scrollPane.setPreferredWidth(this.getScrollWidth());
            m_scrollPane.setMinimumWidth(this.getScrollWidth());
            m_scrollPane.setMaximumWidth(this.getScrollWidth());
            m_dataList.setHGap(0);
        }
        override protected function moveLeft(_arg1:AWEvent):void{
            m_curIndex = (m_curIndex - NUM_ITEMS);
            if (m_curIndex <= 0){
                prevButton.setEnabled(false);
                m_curIndex = 0;
            };
            m_dataList.scrollHorizontal(-(this.getScrollWidth()));
            nextButton.setEnabled(true);
        }
        override protected function moveRight(_arg1:AWEvent):void{
            var _local4:int;
            var _local2:int = m_curCount;
            var _local3:int = Math.min(m_data.length, (m_curCount + NUM_ITEMS));
            if ((_local3 - _local2) > 0){
                if (m_model.getSize() < (NUM_ITEMS + m_curCount)){
                    _local4 = _local2;
                    while (_local4 < _local3) {
                        m_model.append(m_data[_local4]);
                        m_curCount++;
                        m_curIndex++;
                        _local4++;
                    };
                    if (m_curIndex >= (this.m_data.length - NUM_ITEMS)){
                        nextButton.setEnabled(false);
                    };
                };
            } else {
                if (m_curIndex < m_curCount){
                    m_curIndex = (m_curIndex + NUM_ITEMS);
                    if (m_curIndex >= (this.m_data.length - NUM_ITEMS)){
                        nextButton.setEnabled(false);
                        m_curIndex = (m_data.length - NUM_ITEMS);
                    };
                };
            };
            prevButton.setEnabled(true);
            m_dataList.scrollHorizontal(this.getScrollWidth());
        }
        public function getScrollWidth():int{
            return (ROW_WIDTH);
        }

    }
}//package Display.ValentineUI 
